package com.rran.study.chat.ops.enums;

import com.rran.study.chat.ops.pojo.socketmsg.*;
import lombok.Getter;

/**
 * @author yy
 * @Type MessageType.java
 * @Desc
 * @date 2020/8/6 21:50
 */
@Getter
public enum MessageType {
    REGISTER("REGISTER", RegisterMsg.class),
    SINGLE("SINGLE", SingleMsg.class),
    GROUP("GROUP", GroupChatMsg.class),
    ADD_FRIEND("ADD_FRIEND", AddFriendMsg.class),
    ACCEPT_FRIEND("ACCEPT_FRIEND", AcceptFriendMsg.class),
    ;
    String code;
    Class aClass;

    MessageType(String code, Class aClass) {
        this.code = code;
        this.aClass = aClass;
    }

    public static Class getClassByCode(String code) {
        for (MessageType messageType : values()) {
            if (messageType.getCode().equals(code)) {
                return messageType.getAClass();
            }
        }
        return null;
    }
}
